From ad1775c705043a7c9ae195c0a5ee421b6275a55e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 29 Feb 2020 17:14:46 +0000 Subject: [PATCH] Generate locales used by the tests --- debian/changelog | 2 + debian/control.in | 1 + debian/copyright | 6 +- debian/rules | 5 ++ debian/run-with-locales | 122 +++++++++++++++++++++++++++++++++++ debian/tests/control | 2 +- debian/tests/installed-tests | 5 ++ 7 files changed, 140 insertions(+), 3 deletions(-) create mode 100755 debian/run-with-locales diff --git a/debian/changelog b/debian/changelog index 15dbeb5b43..b0fd2327e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,8 @@ gtk+4.0 (3.98.0-1) UNRELEASED; urgency=medium * d/rules: Update SONAME * d/rules: Adjust build options for rename of documentation to gtk_doc * d/rules: Sort build options + * d/run-with-locales, d/rules, d/tests/installed-tests: + Generate locales used by the tests -- Simon McVittie Sat, 29 Feb 2020 14:18:02 +0000 diff --git a/debian/control.in b/debian/control.in index 198bc4bdb1..5eb0970369 100644 --- a/debian/control.in +++ b/debian/control.in @@ -43,6 +43,7 @@ Build-Depends: adwaita-icon-theme , libxkbfile-dev, libxml2-utils, libxrandr-dev (>= 2:1.5.0), + locales | locales-all, meson (>= 0.50.1), pkg-config, sassc, diff --git a/debian/copyright b/debian/copyright index da44c4979c..341b5efeaa 100644 --- a/debian/copyright +++ b/debian/copyright @@ -507,13 +507,15 @@ Copyright: License: LGPL-2+ or sun-permissive Files: + debian/run-with-locales gdk/wayland/cursor/* gtk/inspector/logs.* Copyright: - 2002 Keith Packard - 2012 Collabora Ltd. + 2012-2018 Collabora Ltd. 2012 Intel Corporation + 2002 Keith Packard 2018 Red Hat, Inc. + 2016-2020 Simon McVittie License: Expat Files: diff --git a/debian/rules b/debian/rules index d4591d242c..88939cb82e 100755 --- a/debian/rules +++ b/debian/rules @@ -178,6 +178,11 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) # Remove LD_PRELOAD so we don't run with fakeroot, which makes dbus-related tests fail env -u LD_PRELOAD \ xvfb-run -a -s "-screen 0 1024x768x24" \ + debian/run-with-locales \ + --generate de_DE.UTF-8 \ + --generate en_GB.UTF-8 \ + --generate en_US.UTF-8 \ + --generate sv_SE \ dh_auto_test --builddirectory=debian/build/deb -- -k 0 -j 1 || true endif diff --git a/debian/run-with-locales b/debian/run-with-locales new file mode 100755 index 0000000000..c3b192ba54 --- /dev/null +++ b/debian/run-with-locales @@ -0,0 +1,122 @@ +#!/bin/sh +# +# Run a wrapped command with at least the requested locales available. +# Requires a dependency on locales | locales-all. +# The requested locales must be of the form foo_FOO.utf8, or special-cased +# in generate(). +# +# Copyright 2016-2020 Simon McVittie +# Copyright 2017-2018 Collabora Ltd. +# +# SPDX-License-Identifier: MIT +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +set -eu + +me="$(basename "$0")" +tempdir= + +usage () { + local status="${1-2}" + + if [ "$status" -ne 0 ]; then + exec >&2 + fi + + echo "Usage: $me [--generate LOCALE...] COMMAND [ARGS...]" +} + +getopt_temp=help +getopt_temp="$getopt_temp,generate:" + +getopt_temp="$(getopt -o '' --long "$getopt_temp" -n "$0" -- "$@")" +eval set -- "$getopt_temp" +unset getopt_temp + +generate () { + local locale="$1" + local name + local charset + + case "$locale" in + (*.utf8) + name="${locale%.utf8}" + charset=UTF-8 + ;; + + (sv_SE) + name="$locale" + charset=ISO-8859-1 + ;; + + (*) + echo "$me: Unsupported locale $locale" >&2 + exit 1 + ;; + esac + + if [ -e "/usr/lib/locale/$locale/LC_MESSAGES/SYS_LC_MESSAGES" ]; then + return + fi + + if [ -z "$tempdir" ]; then + tempdir="$(mktemp -d)" + trap 'rm -fr "$tempdir"' EXIT + fi + + localedef -i "$name" -f "$charset" "$tempdir/$locale" +} + +while [ "$#" -gt 0 ]; do + case "$1" in + (--help) + usage 2 + # not reached + ;; + + (--generate) + generate "$2" + shift 2 + ;; + + (--) + shift + break + ;; + + (-*) + echo "$me: Unknown option: $1" >&2 + usage 2 + # not reached + ;; + + (*) + break + ;; + esac +done + +if [ -n "$tmpdir" ]; then + export LOCPATH="$tmpdir" +fi + +"$@" + +# vim:set sw=4 sts=4 et: diff --git a/debian/tests/control b/debian/tests/control index c91fbb221e..2456ac91ed 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -8,5 +8,5 @@ Depends: dbus, gir1.2-gtk-4.0, python3-gi, xauth, xvfb Restrictions: flaky, superficial Tests: installed-tests -Depends: at-spi2-core, dbus (>= 1.8), gnome-desktop-testing (>= 2018.1-1~), gtk-4-examples, xauth, xvfb +Depends: at-spi2-core, dbus (>= 1.8), gnome-desktop-testing (>= 2018.1-1~), gtk-4-examples, locales | locales-all, xauth, xvfb Restrictions: allow-stderr, flaky diff --git a/debian/tests/installed-tests b/debian/tests/installed-tests index 4349fa049f..8848a5ae37 100755 --- a/debian/tests/installed-tests +++ b/debian/tests/installed-tests @@ -13,6 +13,11 @@ export XDG_RUNTIME_DIR="$AUTOPKGTEST_TMP" exec dbus-run-session -- \ xvfb-run -a -s "-screen 0 1024x768x24" \ +debian/run-with-locales \ + --generate de_DE.UTF-8 \ + --generate en_GB.UTF-8 \ + --generate en_US.UTF-8 \ + --generate sv_SE \ gnome-desktop-testing-runner \ --report-directory="$AUTOPKGTEST_ARTIFACTS" \ --tap \ -- 2.30.2